<?php
declare(strict_types=1);
namespace Field;

class QuestionPostCollectConst
{
    public const pk='';
    public const index=['UserID','ThreadID','PostID'];
	public const fields=['UserID','ThreadID','PostID','CreateAt'];
	public const comment=['UserID'=>'用户ID','ThreadID'=>'帖子ID','PostID'=>'内容ID','CreateAt'=>'添加时间'];
	/*
    * @Field UserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 用户ID
    */
    public const UserID = 'UserID';
    /*
    * @Field ThreadID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 帖子ID
    */
    public const ThreadID = 'ThreadID';
    /*
    * @Field PostID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 内容ID
    */
    public const PostID = 'PostID';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 添加时间
    */
    public const CreateAt = 'CreateAt';
}

class QuestionPostCollectColumns
{
public  int $UserID;
   public  int $ThreadID;
   public  int $PostID;
   public  ?string $CreateAt='';
	public function toArray():array
	{
		return [
'UserID'=>$this->UserID,
    'ThreadID'=>$this->ThreadID,
    'PostID'=>$this->PostID,
    'CreateAt'=>$this->CreateAt,        ];
	}
}

class QuestionPostCollectRow
{
	public QuestionPostCollectColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'UserID' => $this->data->UserID,
        'ThreadID' => $this->data->ThreadID,
        'PostID' => $this->data->PostID,
        'CreateAt' => $this->data->CreateAt, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new QuestionPostCollectColumns();
        isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['ThreadID']) && $this->data->ThreadID = (int)$data['ThreadID'];
           isset($data['PostID']) && $this->data->PostID = (int)$data['PostID'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
    }
}
?>